﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XTYAPI.PLC
{

    public   class On_Off_Clk
    {
         TON CycleTime = new TON();
         bool clk=false;

        public  bool GetOn_Off_Clk(uint uiOnTime,uint uiCycle)
        {
            #region 震荡
            CycleTime.PT = uiCycle;
            CycleTime.IN = true;
            if (CycleTime.Qp)
            {
                CycleTime.IN = false;
            }
            #endregion

            #region 输出
            if (CycleTime.ET < uiOnTime)
            {
                clk = true;
            }
            else
            {
                clk = false;
            }
            return clk;
            #endregion
        }
        public bool GetOn_Off_Clk(float PWM, uint uiCycle)
        {
            uint uiOnTime = (uint)(PWM * uiCycle);
            return  GetOn_Off_Clk(uiOnTime, uiCycle);
        }
    }
}
